package com.azier.kapacitor.script.node;

import com.azier.kapacitor.script.method.Delete;
import com.azier.kapacitor.script.method.Idle;
import com.azier.kapacitor.script.method.Period;
import com.azier.kapacitor.script.method.Quiet;
import com.azier.kapacitor.script.node.nodebind.CommonNodeBind;

import java.util.ArrayList;

/**
* 1 * @Author: luoj
* 2 * @Date: 2019/11/8 11:27
* 3
*/

/**
Create a new Barrier node that emits a BarrierMessage periodically
**/
/**
创建一个新的Barrier节点，该节点定期发出BarrierMessage
**/
public class BarrierNode extends AbstractNode implements CommonNodeBind{
    private static final String name = "barrier";

    public BarrierNode() {
        super(new ArrayList<>(),new ArrayList<>(),name);
    }

    /**
    Emit barrier based on idle time since the last received message. Must be greater than zero.
    **/
    /**
    根据自上次收到消息以来的空闲时间发出屏障。必须大于零。
    **/
    public BarrierNode idle(long interval, String durationLiteral){
        Idle idle = new Idle(interval, durationLiteral);
        super.addMethod(idle);
        return this;
    }
    /**
    Emit barrier based on periodic timer. The timer is based on system clock rather than message time. Must be greater than zero.
    **/
    /**
    基于定期计时器的发射屏障。计时器基于系统时钟，而不是消息时间。必须大于零。
    **/
    public BarrierNode period(long interval, String durationLiteral){
        Period period = new Period(interval, durationLiteral);
        super.addMethod(period);
        return this;
    }
    /**
    Delete the group after processing each barrier.
    **/
    /**
    处理完每个障碍后，删除组。
    **/
    public BarrierNode delete(boolean barrier){
        Delete delete = new Delete(barrier);
        super.addMethod(delete);
        return this;
    }
    /**
    Suppress all error logging events from this node.
    **/
    /**
    禁止来自此节点的所有错误记录事件。
    **/
    public BarrierNode quiet(){
        Quiet quiet = new Quiet();
        super.addMethod(quiet);
        return this;
    }
}